package tgc.edu.ljc.layui.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import tgc.edu.ljc.layui.custom.CommonRepository;
import tgc.edu.ljc.layui.entity.Course;
import tgc.edu.ljc.layui.entity.Grade;


@Repository
public interface GradeRepository extends CommonRepository<Grade, Integer>{

	public Page<Grade> findByIdIsNull(Pageable pageable);

	public Grade findByStuIdAndCourseId(Integer stuId, Integer courseId);

	public Page<Grade> findByStuTbClassIdAndCourseId(Integer classId, Integer courseId, Pageable pageable);

	public Page<Grade> findByStuId(Integer stuId, Pageable pageable);
	
	@Query(value="select distinct t.course from Grade t where t.stu.tbClass.id=?1")
	public List<Course> findCoursesByClassId(Integer classId);

	public List<Grade> findByStuId(Integer studentId);

}
